Test Series - Data Structure

Test Number 100/115

Q: Which of the following helps keys to be mapped into addresses?
A. hash function
B. separate chaining
C. open addressing
D. chaining using a linked list
Solution: Hash table is an example of a data structure that is built for fast access of elements. Hash functions are used to determine the index of any input record in a hash table.
Q: What is the advantage of the hash table over a linked list?
A. faster access of data
B. easy to implement
C. very efficient for less number of entries
D. exhibit good locality of reference
Solution: Hash table is a data structure that has an advantage that it allows fast access of elements. But linked list is easier to implement as compared to the hash table.
Q: Which of the following trait of a hash function is most desirable?
A. it should cause less collisions
B. it should cause more collisions
C. it should occupy less space
D. it should be easy to implement
Solution: Hash function calculates and returns the index for corresponding data. So the most important trait of a hash function is that it should cause a minimum number of collisions.
Q: What is the time complexity of insert function in a hash table using list head?
A. O(1)
B. O(n)
C. O(log n)
D. O(n log n)
Solution: Time complexity of insert function in a hash table is O(1). Condition is that the number of collisions should be low.
Q: What is the time complexity of search function in a hash table using list head?
A. O(1)
B. O(n)
C. O(log n)
D. O(n log n)
Solution: Time complexity of search function in a hash table is O(1). Condition is that the number of collisions should be low.
Q: What is the time complexity of delete function in the hash table using list head?
A. O(1)
B. O(n)
C. O(log n)
D. O(n log n)
Solution: Time complexity of delete function in a hash table is O(1). Condition is that the hash function should be such that the number of collisions should be low.
Q: What is the advantage of using linked list over the doubly linked list for chaining?
A. it takes less memory
B. it causes more collisions
C. it makes the process of insertion and deletion faster
D. it causes less collisions
Solution: Singly linked list takes lesser space as compared to doubly linked list. But the time complexity of the singly linked list is more than a doubly linked list.
Q: What is the worst case time complexity of insert function in the hash table when the list head is used for chaining?
A. O(1)
B. O(n log n)
C. O(log n)
D. O(n)
Solution: Worst case time complexity of insert function in the hash table when the list head is used for chaining is O(n). It is caused when a number of collisions are very high.
Q: Which of the following technique is used for handling collisions in a hash table?
A. Open addressing
B. Hashing
C. Searching
D. Hash function
Solution: Open addressing is the technique which is used for handling collisions in a hash table. Separate chaining is another technique which is used for the same purpose.
Q: Which of the following is an advantage of open addressing over separate chaining?
A. it is simpler to implement
B. table never gets full
C. it is less sensitive to hash function
D. it has better cache performance
Solution: Open addressing is the technique which is used for handling collisions in a hash table. It has a better cache performance as everything is stored in the same table.

You Have Score    /10